import { Player } from "/static/js/player/base.js";
import {GIF} from "/static/js/utils/gif.js";

export class Kyo extends Player {
    constructor(root,info) {
        super(root,info);
        
        this.init_animation();
    }

    init_animation() {
        let outer = this;
        let offsets = [0,-22,-22,-120,0,0,0];
        for (let i = 0; i < 7; i ++) {
            let gif = GIF();
            gif.load(`/static/images/player/kyo/${i}.gif`);

            outer.animations.set(i,{
                gif:gif,      // 当前图片
                frame_cnt:0,  // 图片帧数
                frame_rate:5, // 每5帧渲染下一次
                offset_y: offsets[i],   // y方向的偏移量
                loaded:false, // 是否被加载
                scale:2, // 放大多少倍
            });

            gif.onload = function() {   // 出错了与load写重名了
                let obj = outer.animations.get(i);
                obj.frame_cnt = gif.frames.length;
                obj.loaded = true;
                if (i === 3) {
                    obj.frame_rate == 7;
                }
            }
        }
    }
}